/**
 * 路径分析
 * @author cqb
 * @class OpenLayers.Control.BufferAnalysis
 * @extends OpenLayers.Control
 * @version 1.0
 * @requires extend/Control/DrawCircle.js
 */

OpenLayers.Control.BufferAnalysis2 = OpenLayers.Class(OpenLayers.Control.DrawCircle,{
	/**
	 * Property: styleMap OpenLayers.styleMap
	 */
	styleMap : null,

	/**
	 * Property: title {String} 工具按钮提示文字
	 */
	title : "缓冲分析",
	/**
	 * 中心点
	 * @property center
	 * @type {LonLat}
	 */
	center: null,
	/**
	 * 缓冲半径
	 * @property radius
	 * @type {Float}
	 */
	radius: null,
	
	/**
	 * 绘制的样式
	 * @property routeSymbolizers
	 * @type {Object}
	 */
	routeSymbolizers: {
		"Line" : {
			strokeWidth : 3,
			strokeOpacity : 1,
			strokeColor : "#F0987C",
			strokeDashstyle : "solid"
		}
	},
	/**
	 * 绘制矢量图层
	 * @property vectorlayer
	 * @type {Layer}
	 */
	vectorlayer: null,
	
	/**
	 * Method: initialize 初始化
	 */
	initialize : function(options) {
		this.vectorlayer = new OpenLayers.Layer.Vector("缓冲分析Vector",{
			styleMap: this.styleMap
		});
		options.layer = this.vectorlayer;
		
		OpenLayers.Control.DrawCircle.prototype.initialize.apply(this,arguments);
		var style = new OpenLayers.Style();
		style.addRules([ new OpenLayers.Rule({
			symbolizer : this.routeSymbolizers
		}) ]);
		this.styleMap = new OpenLayers.StyleMap({
			"default" : style
		});
	},

	/**
	 * Method: activate 控件被触发时设置鼠标手势
	 */
	activate : function() {
		if(this.vectorlayer){
			this.vectorlayer.removeAllFeatures();
		}
		OpenLayers.Control.DrawCircle.prototype.activate.apply(this,arguments);
	},
	
	setMap: function(map){
		OpenLayers.Control.DrawCircle.prototype.setMap.apply(this,arguments);
		if(this.vectorlayer){
			this.map.addLayer(this.vectorlayer);
		}
	},
	
	/**
	 * 绘制feature
	 * @method drawFeature
	 * @param {Geometry} geometry 
	 */
	drawFeature: function(geometry){
		OpenLayers.Control.DrawCircle.prototype.drawFeature.apply(this,arguments);
		
		this.deactivate();
		
		this.bufferQuery(geometry);
	},
	
	/**
	 * 开始查询 
	 * @method bufferQuery
	 * @param evt {OpenLayers.Event} 事件
	 */
	bufferQuery : function(geometry) {
		this.center = this.handler.center;
		var distance = geometry.getBounds().getWidth() / 2;
		
		this.queryend(this.center, distance);
	},
	
	/**
	 * 查询结束
	 * @method queryend
	 * @param features {Array} 空间对象
	 */
	queryend: function(center, radius){
		
	},
	
	CLASS_NAME : "OpenLayers.Control.BufferAnalysis2"
});